package bradd.Blackjack;

import java.util.ArrayList;
import java.util.Random;



import android.util.StringBuilderPrinter;
import android.widget.Toast;
import android.app.Activity;
import android.content.res.Resources;

	
public class Deck
	{
		public ArrayList<Card> m_deck;
		public ArrayList<Blackjackcard> b_deck;
		
		public Deck()
		{
			NewDeck();
		}
		
		public void NewDeck()
		{
			if (m_deck != null)
				m_deck.clear();
		
		
			m_deck = new ArrayList<Card>();
			
			for (int suit = 0; suit < 4; suit++)
				for (int rank = 0; rank < 13; rank++)
					m_deck.add(new Card(suit, rank));
				
		}
		
				
			
			
		

		public int size()
		{
			return m_deck.size();
		}
		
		public void Shuffle()
		{
			NewDeck();

			Random rnd = new Random(System.currentTimeMillis());
			
			ArrayList<Card> shuffled = new ArrayList<Card>();
			
			for (int i = 51; i > 0; i--)
				shuffled.add(m_deck.remove(rnd.nextInt(i)));
			shuffled.add(m_deck.remove(0));
			
			m_deck = shuffled;
		}
		
		public Card DealCard()
		{
			if (m_deck.size() != 0)
				return m_deck.remove(0);
			else
				return null;
		}
	}